在gridview中调用Javascript [英] Calling Javascript inside gridview

查看:86
本文介绍了在gridview中调用Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想要一个gridview来填充数据库中的详细信息.在网格中,我希望某些列用作超链接.此外,超链接还指向另一个页面,该页面需要超链接查询字符串中的值.我需要通过的细节在网格的其他列中.我尝试了并且部分成功了.我在页面后面的代码中收集列值,并附加导航URL字符串.数据绑定后,我使value列不可见,这样就不会有链接和具有相同值的datafield.

我的问题是有没有简单的方法可以做到这一点???
可能正在使用Java脚本???如果可以,可以给我一些介绍吗?某些示例代码会很棒?
谢谢

Hi,
I want have a gridview populating details from a database. In the grid i want certain colums to be work as hyperlinks. Also hyperlinks directs to another page which expects values in the hyperlink query string. The details which i need to pass is in the other colums of the grid. I tried and partially successfull. I collects the column value in code behind page and append with the navigate url string. After data bind i make the value column invisible so that there wont be a link and a datafield with same value.

My question is is there any simple way to do it???
May be using Java script??? if yes can any one give me some over view??Some sample code will be Great??
Thanks

推荐答案

不要在JavaScript中做到这一点,请使用网格视图模板来实现所需的功能. 示例
Don''t do it in JavaScript, use the grid view templates to achieve what you want. Sample


实际上我不想对该链接进行任何SQl操作.我认为要使用查询字符串中的值将该超链接重定向到其他psges.查询字符串中的值是从Gridview的其他列获取的.
那是问题....


没有人可以回答???:(
Actually I don''t want to do any SQl operation with that link. I juct want to redirect that hyperlink to other psges with values in query string. the values in query string is getting from other columns of the Gridview.
That is the problem ....


No one to answer???:(


所以您不能只使用超链接字段....如下所示

So can''t you just use a hyperlink field....as follows

<asp:GridView ID="SummaryView" runat="server" AutoGenerateColumns="False">
    <Columns>
        <asp:HyperLinkField DataNavigateUrlFields="MyIdentifier" DataNavigateUrlFormatString="~/Pages/ChangeRequestDetails.aspx?requestId={0}"

            DataTextField="MyIdentifier" HeaderText="Request ID">
            <ItemStyle CssClass="reference" />
        </asp:HyperLinkField>
    </Columns>
</asp:GridView>



因此,在上面的GridView示例中,有一个HyperLinkField绑定到一个名为"MyIdentifier"(或任何您喜欢的东西)的数据字段.然后,该字段的值构成DataNavigateUrlFormatString
的一部分
您可以让您的超链接字段使用大量数据值并形成链接URL.例如



So in the above GridView example, there is one HyperLinkField that is bound to a data field called ''MyIdentifier'' (or whatever you like!). The value of the field then forms part of DataNavigateUrlFormatString

You can have your hyperlink field use numerous data values and form the link URL. e.g

<asp:HyperLinkField DataNavigateUrlFields="CustomerID, CompanyName, ContactName, Address, City" DataNavigateUrlFormatString="CustomerDetails.aspx?CID={0}&CName={1}&ContactName={2}&Addr={3}&City={4}" Text="Pass Multiple Values" /> 


这篇关于在gridview中调用Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆