|
在三石大哥的指导下,终于拿出了解决办法,三石大哥建议分享一下,我在此把代码贴出
前台代码:
<f:Grid ID="Grid1" Collapsed="false" BoxFlex="1" Title="报道日期详情表"
ShowBorder="true" ShowHeader="false" runat="server" EnableCollapse="true"
EnableRowDoubleClickEvent="true"
AllowCellEditing="true" DataKeyNames="M1,M2,M3,M4,M5,M6,M7,M8,M9,M10,M11,M12">
<Columns>
<f:BoundField Width="90px" DataField="M1" HeaderText="一" />
<f:BoundField Width="90px" DataField="M2" HeaderText="二" HtmlEncodeFormatString="false"/>
<f:BoundField Width="90px" DataField="M3" HeaderText="三" HtmlEncodeFormatString="false"/>
<f:BoundField Width="90px" DataField="M4" HeaderText="四" HtmlEncodeFormatString="false"/>
<f:BoundField Width="90px" DataField="M5" HeaderText="五" HtmlEncodeFormatString="false"/>
<f:BoundField Width="90px" DataField="M6" HeaderText="六" HtmlEncodeFormatString="false"/>
<f:BoundField Width="90px" DataField="M7" HeaderText="七" HtmlEncodeFormatString="false"/>
<f:BoundField Width="90px" DataField="M8" HeaderText="八" HtmlEncodeFormatString="false"/>
<f:BoundField Width="90px" DataField="M9" HeaderText="九" HtmlEncodeFormatString="false"/>
<f:BoundField Width="90px" DataField="M10" HeaderText="十" HtmlEncodeFormatString="false"/>
<f:BoundField Width="90px" DataField="M11" HeaderText="十一" HtmlEncodeFormatString="false"/>
<f:BoundField Width="90px" DataField="M12" HeaderText="十二" HtmlEncodeFormatString="false"/>
</Columns>
</f:Grid>
后台
protected void Grid1_RowClick(object sender, EventArgs e)
{
int[] tmp = Grid1.SelectedCell;
string data = Grid1.DataKeys[tmp[0]][tmp[1]].ToString();
Alert.ShowInTop(data);
}
要让Grid1.SelectedCell有效重点在于grid的AllowCellEditing="true",不然怎么都是错的
然后得到行列索引后要得到单元格的数据我采用的办法是datakeys,把所有列都按顺序设为DataKeyNames,然后在后台datakeys的数据索引和行列索引就一一对应了,这样取出来的值就是双击的那个单元格的数据咯
办法很拙劣,希望能解决大家遇到的问题,在此我还有个问题,在开原版4.2上如何修改单元格的背景颜色或者字体颜色,希望有解决办法的大神能够帮助我
|
|